<?php
/**
 * Created by PhpStorm.
 * User: lyang
 * Date: 2016/12/31
 * Time: 12:26
 */


class YC
{
    private static $C=[];
    private static $V=[];

    public static function set($key,$value){
        self::$V[$key] = $value;
    }
    public static function get($key){
        return isset(self::$V[$key]) ?self::$V[$key]:'';
    }
    public static function bind($key,$value){
        if(isset(self::$C[$key])){
            return self::$C[$key];
        }else{
            return self::$C[$key] = $value;
        }
    }

    public static function make($key){
        if(isset(self::$C[$key])){
            return call_user_func(self::$C[$key]);
        }else{
            YC::location("/public/p/404.html");
            exit("$key not in Container");
        }
    }
    use YC_TRAIT;
}
trait  YC_TRAIT{
    public static function html($data){
        echo $data;
    }
    public static function location($data){
        header("location:  $data");
    }
    public static function json($data){
        echo json_encode($data);
    }
    public static function dump($data){
        var_dump($data);
    }
}